#ifndef GRAPHICBUTTON_H
#define GRAPHICBUTTON_H

#include <QPushButton>
#include <QLabel>
#include <QTimer>
#include "global.h"

class GraphicButton : public QPushButton
{
    Q_OBJECT
public:
    explicit GraphicButton(int gra_item_index,QWidget *parent = 0);
    //设置位置描述信息
    void set_geo_description_and_num(const QString &inf, const QString &num);
    //初始化标签
    void init_const_member();
    //设置设备logo
    void set_device_logo(const QString &filepath);
    //设置成未定义状态
    void set_undefined_state();

    int get_index(){ return graphic_btn_index; }
    void set_index(int index){ graphic_btn_index = index;}

signals:
    void sig_gra_btn_clicked(int btn_number);

public slots:
    //设置启动灯
    void set_start_led(led_mode flag);
    //设置故障灯
    void set_fault_led(led_mode flag);
    //设置反馈灯
    void set_fedback_led(led_mode flag);

private slots:
    void gra_btn_clicked();
    void blink_led();

private:
    QLabel *device_logo;		//设备图标
    QLabel *geo_descrption;	//位置描述
    QLabel *label_number;		//编号
    QLabel *number;			//编号值
    QLabel *start_led;			//启动ｌｅｄ
    QLabel *fedback_led;		//反馈ｌｅｄ
    QLabel *fault_led;			//故障ｌｅｄ

    int graphic_btn_index;
    bool flag;
    QTimer *blink_timer;
};

#endif // GRAPHICBUTTON_H
